package com.how.warlock.engine;

import java.io.IOException;

import org.lwjgl.opengl.GL11;

import com.how.warlock.art.Art;

import static org.lwjgl.opengl.GL11.*;

public class Sprite {
	Texture texture;
	
	private int width;
	private int height;
	
	public Sprite(){
	}
	
	public Sprite(Texture texture){
			this.texture = texture;
			width = texture.getImageWidth();
			height = texture.getImageHeight();
	}
	
	public int getWidth(){
		return width;
	}
	
	public int getHeight(){
		return height;
	}
	
	public void draw(int x, int y){
		glPushMatrix();
		glEnable(GL_TEXTURE_2D);
		
		texture.bind();
		
		GL11.glColor3f(1f, 1f, 1f);
		
		glTranslatef(x,y,0);

		
		glBegin(GL_QUADS);{
			glTexCoord2f(0, 0);
			glVertex2f(0, 0);
			
			glTexCoord2f(0, texture.getHeight());
		
			glVertex2f(0, height);
			
			glTexCoord2f(texture.getWidth(), texture.getHeight());
			glVertex2f(width, height);
			
			glTexCoord2f(texture.getWidth(), 0);
			glVertex2f(width, 0);
		}
		
		glEnd();
		
		glPopMatrix();
	}
}
